<?php
	require '../../include/library.inc.php';
	require '../../include/admin_login.inc.php';
	
	
	$id =$_REQUEST["db"];
	$cx = $_REQUEST["cx"];
	if($id) {
	
		$sql = "UPDATE catalog_image
							SET
								top = '0'
							WHERE
								catalog_id = '".$cx."'
							  ";
		query($sql);
		
		$sql = "UPDATE catalog_image
							SET
								top = '1'
							WHERE
								image_id = '".$id."'
							  ";
		query($sql);
		
		$_SESSION['message'] = 'Успешно променихте корицата!';
	}
	//redirect($_SERVER['HTTP_REFERER']);
	
	redirect( 'catalog_edit.php?catalog_id='.$cx);
?>